package com.youku.component.variable;

import com.youku.component.BaseAttribute;
import com.youku.component.Step;
import com.youku.expression.Expression;
import com.youku.expression.Position;

/**
 * 变量
 * 
 * @author loda
 *
 */
public class Variable implements Step {

	protected String name;

	protected Expression expression;

	protected BaseAttribute attribute;
	
	public Variable() {
		super();
	}

	public Variable(String name, String expressionString, BaseAttribute attribute) {
		this.name = name;
		this.expression = new Expression(Position.create(attribute), expressionString);
		this.attribute = attribute;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setExpression(String expressionString) {
		this.expression = new Expression(Position.create(attribute), expressionString);
	}

	@Override
	public void run() {
		attribute.addVariable(name, expression.get());
	}

	@Override
	public String getKey() {
		return null;
	}
}
